package org.springblade.modules.admin.vo;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import org.springblade.common.cache.DictCache;
import org.springblade.modules.admin.enums.MaintainPlanContentEnum;
import org.springblade.modules.admin.utils.DateUtils;

import java.util.Date;

/**
 * @Date 10:29 2024/5/23
 * @Description {
 *   电梯运行状态列表
 * }
 * @Author lsay
 **/
@Data
public class ElevatorStopLogListVO {

	/**
	 * 电梯id
	 */
	private Long elevatorId;

	/**
	 * 项目id
	 */
	private Long buildingId;

	/**
	 * 项目名称
	 */
	private String buildingName;

	/**
	 * 电梯地址
	 */
	private String elevatorAddress;

	/**
	 * 电梯实时状态： 1-正常 2-停梯
	 */
	private Integer isStop;

	/**
	 * 变更时间
	 */
	private Date createTime;

	/**
	 * 实时停梯时长
	 */
	private Long realTimeDuration;

	/**
	 * 实时停梯时长描述
	 */
	private String realTimeDurationStr;

	/**
	 * 停梯类型 2-设备维护 1-设备故障 3-非设备故障
	 */
	private Integer stopType;

	/**
	 * 停梯类型名称
	 */
	private String stopTypeName;

	/**
	 * 停梯原因
	 */
	private String stopTypeDesc;

	/**
	 * 近7天累计时长
	 */
	private Long weekDuration;

	/**
	 * 近7天累计时长描述
	 */
	private String weekDurationStr;

	/**
	 * 近30天累计时长
	 */
	private Long monthDuration;

	/**
	 * 近30天累计时长描述
	 */
	private String monthDurationStr;

	/**
	 * 近7天累计停梯次数
	 */
	private Integer weekCount;

	/**
	 * 近30天累计停梯次数
	 */
	private Integer monthCount;

	/**
	 * 操作渠道
	 */
	private Integer source;

	/**
	 * 操作渠道名称
	 */
	private String sourceName;

	/**
	 * 工单id
	 */
	private String planId;

	/**
	 * 模块值
	 */
	private Integer module;

	/**
	 * 模块名称
	 */
	private String moduleName;

	/**
	 * 电梯报障状态 1-正常,2-停梯
	 */
	private Integer faultElevatorStop;

	/**
	 * 报障时间
	 */
	private Date faultCreateTime;

	/**
	 * 项目电梯数量
	 */
	private Integer elevatorCount;

	/**
	 * 是否驻点: 1-不限，2-驻点
	 */
	private Integer stagnationPoint;

	/**
	 * 项目 区code
	 */
	private String adCode;

	/**
	 * 项目 区名称
	 */
	private String adName;

	/**
	 * 项目类型dict_key
	 */
	private String buildingType;

	/**
	 * 项目类型dict_value
	 */
	private String buildingTypeValue;

	/**
	 * 项目地址
	 */
	private String buildingAddress;

	/**
	 * 开始时间 查询报障时间用
	 */
	private String startFaultTime;

	/**
	 * 结束时间 查询报障时间用
	 */
	private String endFaultTime;

	/**
	 * 开始时长 查询用
	 */
	private Integer startDuration;

	/**
	 * 结束时长 查询用
	 */
	private Integer endDuration;

	/**
	 * 开始时间 查询变更时间用
	 */
	private String startCreateTime;

	/**
	 * 结束时间 查询变更时间用
	 */
	private String endCreateTime;

	/**
	 * 排序 查询排序用 默认 1-变更时间倒序 2-变更时间正序
	 */
	private Integer sort;

	public void setStopType(Integer stopType) {
		this.stopType = stopType;
		if(stopType != null){
			switch (stopType){
				case 1:
					this.stopTypeName = "设备故障";
					break;
				case 2:
					this.stopTypeName = "设备维护";
					break;
				case 3:
					this.stopTypeName = "非设备故障";
					break;
				default:this.stopTypeName = "--";
			}
		}
	}

	public void setSource(Integer source) {
		this.source = source;
		if(source != null){
			switch (source){
				case 0:
					this.sourceName = "维保租户后台";
					break;
				case 1:
					this.sourceName = "维保小程序";
					break;
				case 2:
					this.sourceName = "物业小程序";
					break;
				default:this.sourceName = "--";
			}
		}
	}

	public void setModule(Integer module) {
		this.module = module;
		if(module != null){
			if(module == -1){
				this.moduleName = "电梯运行管理";
			}else {
				this.moduleName = MaintainPlanContentEnum.getName(module);
			}
		}
	}

	public void setBuildingType(String buildingType) {
		if(ObjectUtil.isNotEmpty(buildingType)){
			this.buildingTypeValue = DictCache.getValue("building_type",buildingType);
		}
		this.buildingType = buildingType;
	}

	public void setRealTimeDuration(Long realTimeDuration) {
		this.realTimeDuration = realTimeDuration;
		if(realTimeDuration != null && realTimeDuration > 0){
			this.realTimeDurationStr = DateUtils.millisecondToTime(realTimeDuration);
		}
	}

	public void setWeekDuration(Long weekDuration) {
		this.weekDuration = weekDuration;
		if(weekDuration != null && weekDuration > 0){
			this.weekDurationStr = DateUtils.millisecondToTime(weekDuration);
		}
	}

	public void setMonthDuration(Long monthDuration) {
		this.monthDuration = monthDuration;
		if(monthDuration != null && monthDuration > 0){
			this.monthDurationStr = DateUtils.millisecondToTime(monthDuration);
		}
	}
}
